# -*-coding = utf-8 -*-

# @Time: 2021/4/12 0:36
# @Author: bistro
# @File: p179.py
# @Software: PyCharm
from typing import List


class Solution:
    def largestNumber(self, nums: List[int]) -> str:

        if len(nums) == 1:
            return str(nums[0])
        nums.sort(key=CompareTo)
        print(nums)
        if nums[0] == 0:
            return "0"
        return "".join(map(str, nums))


class CompareTo(str):
    def __lt__(self, y):
        return self + y > y + self


# class Solution:
#     def largestNumber(self, nums: List[int]) -> str:
#         n = len(nums)
#         for i in range(n-1):
#             for j in range(n - 1 - i):
#                 str1 = str(nums[j])+str(nums[j+1])
#                 str2 = str(nums[j+1]) + str(nums[j])
#                 if str1 > str2:
#                     temp = nums[j]
#                     nums[j] = nums[j+1]
#                     nums[j+1] = temp
#         res = [str(nums[k]) for k in range(n-1, -1, -1)]
#         if res[0] == "0":
#             return "0"
#         print("".join(res))
#         return "".join(res)


s = Solution()
print(s.largestNumber([0, 0, 0, 0, 0, 0]))
